#include<stdio.h>
#include<algorithm>
#include<math.h>
const int maxn=10001;
using namespace std;
int n,m,p[11]; 
bool isprime[maxn];
void sieve(){
    for(int i=0;i<=maxn;i++)isprime[i]=true;
    isprime[0]=isprime[1]=false;
    for(int i=2;i<=maxn;i++){
        if(isprime[i]){
            for(int j=2*i;j<=maxn;j+=i){
                isprime[j]=false;
            }
        }
    }
}
int binsearch(int m){
    int h=1,l=10,mid ;
    while (l>=h)
    {
        mid=(h+l)/2;
        if(m<p[mid])h=mid+1;
        else if(m>p[mid])l=mid-1;
        else return mid;
        
    }
    return -1;

}

int main(){
    sieve();
    scanf("%d",&n);
    int count=0;
    while (count<10)
    { 
        if (isprime[n])
        {   count++;
            p[count]=n;
        }
        n--;
    }
    for (int i = 1; i <=10; i++)
    {   if (p[i]<=1)break;
        printf("%d\t",p[i]);
    }
    printf("\ninput a prime:");
    scanf("%d",&n);
    m=binsearch(n);
    printf("%d\t",m);
   return 0;
}